#pragma once
#include"Tests.h"
#include <iostream>
#include <vector>
#include<queue>
#include"Graph_Functions.h"
#include<random>
#include"Tarjan.h"
using namespace std;

vector<bool> TwoSAT(int Variables, vector<pair<int, int> > Note)
{
	int Num_Strings = Note.size();
	vector<pair<int, int> > Graph;
	for(int cur = 0; cur < Num_Strings; ++cur)
	{
		int first, second;
		first = Note[cur].first;
		second = Note[cur].second;
		
		Graph.push_back(make_pair(-first, second));
		Graph.push_back(make_pair(-second, first));
	}

	for(int edge = 0; edge < Graph.size(); ++edge)
	{
		int first = Graph[edge].first;
		int second = Graph[edge].second;
		if (first > 0) first = 2*first - 2;
		if (first < 0) first = -2*first - 1;
		Graph[edge].first = first;
		if (second > 0) second = 2*second - 2;
		if (second < 0) second = -2*second - 1;
		Graph[edge].second = second;
	}
	
	auto graph = compact_graph(2*Variables, Graph);

	vector<int> Cool_Sort = component(graph);
	vector<bool> Values(Variables + 1, false);

<<<<<<< .mine
=======
	//for(int i=  0; i<Cool_Sort.size(); ++i) cout << Cool_Sort[i] << " ";
	//cout << "\n";//while(1){};
>>>>>>> .r86
	Values[0] = 1;
	for(int cur_var = 1; cur_var <= Variables; ++cur_var)
	{
<<<<<<< .mine
		if (Cool_Sort[2*cur_var - 2] == Cool_Sort[2*cur_var - 1])
		{
			Values[0] = 0; 
			break;
		}
		if (Cool_Sort[2*cur_var - 2]  > Cool_Sort[2*cur_var - 1])
			Values[cur_var] = true;
=======
		if (Cool_Sort[2*cur_var - 2] == Cool_Sort[2*cur_var - 1])
		{
			Values[0] = 0; 
			//cout << "NEIN!\n"; 
			break;
		}
		if (Cool_Sort[2*cur_var - 2]  > Cool_Sort[2*cur_var - 1])
			Values[cur_var] = true;
>>>>>>> .r86
	}

	return Values;

}
